// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: wsfuyibing <682805@qq.com>
// Date: 2025-01-07

package types

// Accessible is a modifier for resource. If the value is "yes", it means that
// all users can access the resource, otherwise users must hold the specified
// permission to access it.
//
// Users must hold "user:add" permission to access the "/api/user/add" resource
// as the value of accessible not 'yes' for following example.
//
//	{
//	   "accessible": "no",
//	   "permission": "user:add",
//	   "resource": "/api/user/add",
//	   "description": "Add a user"
//	}
//
// All users can access the "/api/auth/login" resource as the value of accessible
// is 'yes' for following example.
//
//	{
//	   "accessible": "yes",
//	   "permission": "user:login",
//	   "resource": "/api/auth/login",
//	   "description": "User sign in"
//	}
type Accessible string

const (
	AccessibleEmpty Accessible = ""
	AccessibleYes   Accessible = "yes"
)

func (o Accessible) IsEmpty() bool  { return o == AccessibleEmpty }
func (o Accessible) IsYes() bool    { return o == AccessibleYes }
func (o Accessible) String() string { return string(o) }
